package cn.jnetty.remoting.tcp;
import cn.jnetty.api.JnettyHandler;
import cn.jnetty.remoting.code.JnettyTcpWrapperIoMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author 猪哥亮
 * @email 1030681978@qq.com
 * @date 2020/4/2 17:51
 * 描述：
 */
@io.netty.channel.ChannelHandler.Sharable
public class JnettyTcpSimpleChannelInboundHandlerImpl extends SimpleChannelInboundHandler<JnettyTcpWrapperIoMessage> {
    private final JnettyHandler<JnettyTcpWrapperIoMessage> jnettyHandler;
    public JnettyTcpSimpleChannelInboundHandlerImpl(JnettyHandler<JnettyTcpWrapperIoMessage> jnettyHandler){
        this.jnettyHandler = jnettyHandler;
    }
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, JnettyTcpWrapperIoMessage msg) throws Exception {
        jnettyHandler.channelRead0(ctx,msg);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        jnettyHandler.channelActive(ctx);
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        jnettyHandler.channelInactive(ctx);
    }

    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        jnettyHandler.userEventTriggered(ctx,evt);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        jnettyHandler.exceptionCaught(ctx,cause);
    }
}
